<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>组织机构树</title>
	<meta name="renderer" content="webkit">	
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
	<meta name="apple-mobile-web-app-status-bar-style" content="black">	
	<meta name="apple-mobile-web-app-capable" content="yes">	
	<meta name="format-detection" content="telephone=no">	
	<link rel="stylesheet" type="text/css" href="/bsc/static/common/layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="/bsc/static/common/bootstrap/css/bootstrap.css" media="all">
	<link rel="stylesheet" type="text/css" href="/bsc/static/common/global.css" media="all">
	<link rel="stylesheet" type="text/css" href="/bsc/static/css/personal.css" media="all">
</head>
<body>
<section class="layui-larry-box">
			<div class="larry-personal">
				<div class="layui-tab">
				   <form action="" method="post">
						<div class="layui-inline">
							<div class="layui-input-inline">
								<input value="${dept_name }" placeholder="请输入组织名称" class="layui-input search_input"   name="dept_name" type="text">
							</div>
							<a class="layui-btn search_btn">查询</a>
						</div>
						<div class="layui-inline">
							<a class="layui-btn layui-btn-normal newsAdd_btn">添加机构</a>
						</div>
				   </form>		
					<!-- 操作日志 -->
						<table class="layui-table">
							<colgroup>
								<col width="5%">
								<col width="9%">
								<col width="9%">
								<col width="9%">
								<col width="9%">
								<col width="9%">
								<col width="9%">
								<col width="15%">
							</colgroup>
					<thead>
						<tr>
							<th style="text-align:left;">编号</th>
							<th>机构名称</th>
							<th>机构代码</th>
							<th>主要负责人</th>
							<th>电话</th>
							<th>传真</th>
							<th>地址</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody class="news_content">
						<c:forEach items="${dept }" var="d" varStatus="s">
						<tr> 
						   <!--style="display: none;"隐藏  -->
						    <td hidden class="td">${d.cascade_id }</td>
							<td align="left">${s.index+1 }</td>
							<td>${d.dept_name }</td>
							<td>${d.dept_code }</td>
							<td>${d.manager }</td>
							<td>${d.phone }</td>
							<td>${d.fax }</td>
							<td>${d.address }</td>
							<td>
								<a class="layui-btn layui-btn-mini news_edit"><i class="iconfont icon-edit"></i> 编辑</a>
								<a class="layui-btn layui-btn-danger layui-btn-mini news_del" data-id="12"><i class="layui-icon"></i> 删除</a>
							</td>
						</tr>
						</c:forEach>
					</tbody>
					</table>
                     <div class="larry-table-page clearfix">
				          <div id="page" class="page"></div>
			         </div>
</section>
<script type="text/javascript" src="/bsc/static/common/layui/layui.js"></script>
<script type="text/javascript">
	layui.use(['jquery','layer','element','laypage'],function(){
	      window.jQuery = window.$ = layui.jquery;
	      window.layer = layui.layer;
          var element = layui.element(),
              laypage = layui.laypage;
          laypage({
					cont: 'page',
					pages: '${page.total}',//总页数
					groups: 3, //连续显示分页数
					curr: '${page.current}' , //固定当前页
				    
					jump: function(obj, first) {
						//得到了当前页，用于向服务端请求对应数据
						var curr = obj.curr;
						//alert(curr+"   1")
						if(!first) {
							//layer.msg('第 '+ obj.curr +' 页');
							//alert(curr+"   1")
							document.forms[0].action="/bsc/systemdept/listAll?curr="+curr;
							document.forms[0].submit();
						}
					}
				});
        //添加文章
  		//改变窗口大小时，重置弹窗的高度，防止超出可视区域（如F12调出debug的操作）
  	   $(window).one("resize",function(){
  			$(".newsAdd_btn").click(function(){
  				var index = layui.layer.open({
  					title : "<font size='4'>&nbsp;&nbsp;<b>添加组织</b></font><font color='red' size='2'>&nbsp;&nbsp;(&nbsp;&nbsp*&nbsp;&nbsp;&nbsp;是必填选项&nbsp;&nbsp)</font>&nbsp;",
  					type : 2,
  					content : "/bsc/systemdept/add",
  					success : function(layero, index){
  						setTimeout(function(){
  							layui.layer.tips('点击此处返回机构列表,不自动保存数据 ', '.layui-layer-setwin .layui-layer-close', {
  								tips: 3
  							});
  						},500)
  					}
  				})			
  				layui.layer.full(index);
  			})
  		}).resize();
  	    
  	    // 删除
  	    //  删除
  	   $("body").on("click",".news_del",function(){  //删除
  			//var _this = $(this).children("td:eq(0)").text();
  			var _this=$(this).parents("tr").find(".td").text();
  			layer.confirm('点击确定将会删除此机构下<br>   所有机构信息！！！',{icon:3, title:'提示信息'},function(index){
  			$.ajax({
	             type: "post",
	             url: "/bsc/systemdept/delDept",
	             data: {deptid:_this},
	             dataType: "json",
	             success: function(data){
	            	 //parent.location.reload();   刷新ifrom页面
	            	 parent.location.reload();
	             }
	                        
             });
  				//document.forms[0].action="/bsc/systemdept/delDept?deptid="+_this;
				//document.forms[0].submit();
  				layer.close(index);
  			});
  		});
        
  		//  查询
  		//  查询
	   $(".search_btn").click(function(){
		  // console.log(${dept});
			document.forms[0].action="/bsc/systemdept/listAll";
			document.forms[0].submit();
	   });
  	    
  	    //修改
  	       //  修改
  	//改变窗口大小时，重置弹窗的高度，防止超出可视区域（如F12调出debug的操作）
   	   $(window).one("resize",function(){
   		$("body").on("click",".news_edit",function(){  //编辑
   		//layer.alert('您点击了文章编辑按钮，由于是纯静态页面，所以暂时不存在编辑内容，后期会添加，敬请谅解。。。',{icon:6, title:'文章编辑'});
   			var _this=$(this).parents("tr").find(".td").text();
   				var index = layui.layer.open({
   					title : "修改",
   					type : 2,
   					content : "/bsc/systemdept/updatedept?deptid="+_this,
   					success : function(layero, index){
   						setTimeout(function(){
   							layui.layer.tips('点击此处返回文章列表,不自动保存数据 ', '.layui-layer-setwin .layui-layer-close', {
   								tips: 3
   							});
   						},500)
   					}
   				})	
   				layui.layer.full(index);
   			})
   		}).resize();
  		
 });
</script>
</body>
</html>